package cn.xiangxiang.controller.order;

import cn.xiangxiang.pojo.order.CagetoryReport;
import cn.xiangxiang.pojo.order.Order;
import cn.xiangxiang.pojo.order.OrderVoItem;
import cn.xiangxiang.service.order.CagetoryReportService;
import cn.xiangxiang.service.order.OrderService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Reference
    private OrderService orderService;

    @Reference
    private CagetoryReportService cagetoryReportService;

    @RequestMapping("/findall")
    public List<Order> findall(){
        return orderService.findAll();
    }
    @RequestMapping("/findall2")
    public List<OrderVoItem> findall2(){
        return orderService.findOrderVoItemList();
    }

    @RequestMapping("/findConditionPage")
    public Page<Order> findConditionPage(Integer startpage, Integer pagesize, @RequestBody Order order){
        return orderService.findConditionPage(startpage,pagesize,order);
    }

    @RequestMapping("/findOrderVoItemByOrderId")
    public OrderVoItem findOrderVoItemByOrderId(String id){
        return orderService.findOrderVoItemByOrderId(id);
    }

    @RequestMapping("/countCagetoryReport")
    public List<CagetoryReport> countCagetoryReport() {
//        LocalDate localDate = LocalDate.now().minusDays(1);
        LocalDate localDate = LocalDate.of(2019, 4, 15);
        return cagetoryReportService.countCagetoryReport(localDate);
    }

    @RequestMapping("/count1Category")
    public List<Map> count1Category(String startDate,String endDate) {
        return cagetoryReportService.count1Category(startDate,endDate);
    }
}
